﻿using Bank_database_system.财务部;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Bank_database_system
{
    public partial class 资金调度b : UserControl
    {
        public event EventHandler ButtonBack;
        public 资金调度b()
        {
            InitializeComponent();
            textBox1.Text = AccountCheck.branchname;
        }

        private void 资金调度b_Load(object sender, EventArgs e)
        {

        }

        private void button8_Click(object sender, EventArgs e)
        {
            ButtonBack?.Invoke(this, EventArgs.Empty);
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar))
            {
                e.Handled = true;
            }
        }

        private void button9_Click(object sender, EventArgs e)
        {
            decimal amount;
            bool success = decimal.TryParse(textBox2.Text, out amount);
            if (success && amount > 0)
            {
                string target = Finance.GetBranchID(textBox3.Text);
                if (target != null && target != string.Empty) {
                    Finance.Funds_Transport(AccountCheck.branchid, target, comboBox1.Text, amount);
                }
            }
            else
            {
                MessageBox.Show("金额输入非法！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }

        private void textBox3_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar))
            {
                e.Handled = true;
            }
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
    }
}
